package cn.itcast.com.homework.day721;
/*
3. 实现如下多态案例，分别定义Person类，SouthPerson(表示南方人)，NorthPerson(表示北方人)
Person
  eat()

SouthPerson
   eat()

NorthPerson
   eat()
写代码实现，eat方法的多态效果
1:人要吃饭
2:南方人吃炒菜和米饭
3:北方人吃烩菜和馒头
 */
public class test {
    public static void main(String[] args) {
        Person person = new Person();
        SouthPerson southPerson = new SouthPerson();
        NorthPerson northPerson = new NorthPerson();
        personEat(person);
        personEat(southPerson);
        personEat(northPerson);
        //两种方式
        System.out.println("*************");
        person.eat();
        person = new SouthPerson();
        person.eat();
        person = new NorthPerson();
        person.eat();
    }
    public static void personEat(Person person){
        person.eat();
    }
}

class Person{
    public void eat(){
        System.out.println("人要吃饭");
    }
}
class SouthPerson extends Person{
    public void eat(){
        System.out.println("南方人吃炒菜和米饭");
    }
}
class NorthPerson extends Person{
    public void eat(){
        System.out.println("北方人吃烩菜和馒头");
    }
}